import request from "@/utils/request"

// 获取组织列表
export function getOrgList(id) {
    return request({
        url: `/api/app/identity/getOrg/${id}`,
        method: "get",
        baseURL: public_config.control_api,
    })
}

// 获取岗位列表
export function getJobsList(data) {
    return request({
        url: `/api/app/identity/getUserJobs`,
        method: "post",
        baseURL: public_config.control_api,
        data
    })
}

// 获取部门列表
export function getDepartmentsList(data) {
    return request({
        url: `/api/app/identity/getUserDepartments`,
        method: "post",
        baseURL: public_config.control_api,
        data
    })
}


// 获取用户列表
export function getUserList(params) {
    return request({
        url: `/api/app/identity/userSearch`,
        method: "get",
        baseURL: public_config.control_api,
        params
    })
}

// 获取角色列表
export function getRoleList(params) {
    return request({
        url: `/api/app/identity/roles`,
        method: "get",
        baseURL: public_config.control_api,
        params
    })
}

// 新增角色
export function addRole(data) {
    return request({
        url: `/api/identity/roles/create-to-organization`,
        method: "post",
        baseURL: public_config.configuration_api,
        data
    })
}

// 修改角色
export function putRole(data) {
    return request({
        url: `/api/identity/roles/${data.id}`,
        method: "put",
        baseURL: public_config.configuration_api,
        data
    })
}

// 删除角色
export function delRole(id) {
    return request({
        url: `/api/app/identity/deleteRole/${id}`,
        method: "post",
        baseURL: public_config.control_api,
    })
}


// 新增人员
export function addUser(data) {
    return request({
        url: `/api/identity/users/create-to-organizations`,
        method: "post",
        baseURL: public_config.configuration_api,
        data
    })
}

// 删除人员
export function delUser(id) {
    return request({
        url: `/api/app/identity/deleteUser/${id}`,
        method: "post",
        baseURL: public_config.control_api,
    })
}

// 编辑人员
export function putUser(data) {
    return request({
        url: `/api/identity/users/${data.id}/update-to-organizations`,
        method: "put",
        baseURL: public_config.configuration_api,
        data
    })
}

// 获取人员组织
export function orgUser(id) {
    return request({
        url: `/api/identity/users/${id}/organizations`,
        method: "get",
        baseURL: public_config.configuration_api,
        param: { id: id }
    })
}

// 获取人员角色
export function roleUser(id) {
    return request({
        url: `/api/identity/users/${id}/roles`,
        method: "get",
        baseURL: public_config.configuration_api,
        param: { id: id }
    })
}

// 人员功能权限列表
export function getUserPermissions(params) {
    return request({
        url: `/api/permission-management/permissions`,
        method: "get",
        baseURL: public_config.configuration_api,
        params
    })
}

// 修改人员功能权限列表
export function putUserPermissions(providerKey, providerName, data) {
    return request({
        url: `/api/permission-management/permissions?providerKey=${providerKey}&providerName=${providerName}`,
        method: "put",
        baseURL: public_config.configuration_api,
        data
    })
}

// 获取人员组织编号
export function getUserOrgCode(params) {
    return request({
        url: `api/app/identity/andGetOrgId`,
        method: "post",
        baseURL: public_config.control_api,
        params
    })
}

// 验证手机号是否存在
export function exitsPhone(params) {
    return request({
        url: `api/app/identity/exitsPhone`,
        method: "post",
        baseURL: public_config.control_api,
        headers: { isLoading: false },
        params
    })
}


// 获取树形部门用户
export function getOrgUsersTree(params) {
    return request({
        url: `api/app/identity/userTreeList`,
        method: "get",
        baseURL: public_config.control_api,
        params
    })
}
